package com.google.cbmgraph;

import com.google.cbmgraph.data.DataSource;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebSettings;
import android.webkit.WebView;

public class WebGraphFragment extends Fragment{
	 private WebView viewer = null;
		/** Called when the activity is first created. It recreates a webview object and
		 * it turns javascript on because the page that displays the graph demands it */
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
	        Bundle savedInstanceState) {

		Log.v("WebGraphFragment", "I'm in the fragment");
	    viewer = (WebView) inflater.inflate(R.layout.web_graph, container, false);	
	    WebSettings webSettings = viewer.getSettings();
	    webSettings.setJavaScriptEnabled(true);
	    return viewer;
	}
	/**Loads the appropriate URL. */
	public void setText(String item) {
		if (viewer != null){
		    viewer.loadUrl(DataSource.URL+"Stupid.html?test="+item);			
		}
	}
}
